package com.chixing.day16.IODemo;

import java.io.*;

/**
 * 适用于文本形式
 */
public class BufferReadDemo {
    public static void main(String[] args) {

        BufferedWriter bw = null;
        BufferedReader br = null;
        try {
            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("//Users//jasonmarslyon//CX_Workspace//Java_Workspace//Test1//hello.txt")), 1024);//字符流，字符字节转换流（字节流->字符流），字节流
            br = new BufferedReader(new InputStreamReader(new FileInputStream("//Users//jasonmarslyon//CX_Workspace//Java_Workspace//Test//hello.txt")));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        int temp;
        try {
            while ((temp = br.read()) != -1) {
                bw.write((byte) temp);
            }
            bw.flush(); //刷新缓冲区
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (bw != null) {
                try {
                    bw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
